<!DOCTYPE html>


<html lang="en">

<!-- begin::Head -->
<head>
    <base href="../../../">
    <meta charset="utf-8"/>
    <title>登录</title>
    <meta name="description" content="Login page example">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">

    <!--end::Fonts -->

    <!--begin::Page Custom Styles(used by this page) -->
    <link href="/public/assets/css/pages/login/login-3.css" rel="stylesheet" type="text/css"/>

    <!--end::Page Custom Styles -->

    <!--begin::Global Theme Styles(used by all pages) -->
    <link href="/public/assets/plugins/global/plugins.bundle.css" rel="stylesheet" type="text/css"/>
    <link href="/public/assets/css/style.bundle.css" rel="stylesheet" type="text/css"/>

    <!--end::Global Theme Styles -->

    <!--begin::Layout Skins(used by all pages) -->
    <link href="/public/assets/css/skins/header/base/light.css" rel="stylesheet" type="text/css"/>
    <link href="/public/assets/css/skins/header/menu/light.css" rel="stylesheet" type="text/css"/>
    <link href="/public/assets/css/skins/brand/dark.css" rel="stylesheet" type="text/css"/>
    <link href="/public/assets/css/skins/aside/dark.css" rel="stylesheet" type="text/css"/>

    <!--end::Layout Skins -->
    <link rel="shortcut icon" href="/public/assets/media/logos/favicon.ico"/>
</head>

<!-- end::Head -->

<!-- begin::Body -->
<body class="kt-quick-panel--right kt-demo-panel--right kt-offcanvas-panel--right kt-header--fixed kt-header-mobile--fixed kt-subheader--enabled kt-subheader--fixed kt-subheader--solid kt-aside--enabled kt-aside--fixed kt-page--loading">

<!-- begin:: Page -->
<div class="kt-grid kt-grid--ver kt-grid--root">
    <div class="kt-grid kt-grid--hor kt-grid--root  kt-login kt-login--v3 kt-login--signin" id="kt_login">
        <div class="kt-grid__item kt-grid__item--fluid kt-grid kt-grid--hor"
             style="background-image: url(/public/assets/media/bg/bg-3.jpg);">
            <div class="kt-grid__item kt-grid__item--fluid kt-login__wrapper">
                <div class="kt-login__container">
                    <div class="kt-login__logo">

                    </div>
                    <div class="kt-login__signin">
                        <div class="kt-login__head">
                            <h3 class="kt-login__title">登录系统</h3>
                        </div>
                        <form class="kt-form" onsubmit="return false;" id="loginForm">
                            <div class="center">
                                <label class="kt-radio kt-radio--bold kt-radio--success">
                                    <input type="radio" value="3" name="role" checked> 学生
                                    <span></span>
                                </label>
                                &nbsp;&nbsp;&nbsp;
                                <label class="kt-radio kt-radio--bold kt-radio--success">
                                    <input type="radio" value="2" name="role"> 教师
                                    <span></span>
                                </label>
                                &nbsp;&nbsp;&nbsp;
                                <label class="kt-radio kt-radio--bold kt-radio--success">
                                    <input type="radio" value="1" name="role"> 管理员
                                    <span></span>
                                </label>
                            </div>
                            <div class="input-group">
                                <input class="form-control" type="text" placeholder="用户名" name="name" required
                                       autocomplete="off">
                            </div>
                            <div class="input-group">
                                <input class="form-control" type="password" placeholder="密码" name="password" required>
                            </div>

                            <div class="input-group">
                                <div class="row">
                                    <div class="col-8">
                                        <input class="form-control" type="text" placeholder="验证码" name="code" required>
                                    </div>
                                    <div class="col-4">
                                        <img src="/home/auth/verify" alt="" style="width: 140px;margin-top: 22px;"
                                             onclick="this.src=this.src+'?'+Math.random()">
                                    </div>
                                </div>
                            </div>

                            <div class="kt-login__actions">
                                <button id="loginBtn"
                                        class="btn btn-brand btn-elevate kt-login__btn-primary">登录
                                </button>
                            </div>
                        </form>
                    </div>
                    <div class="kt-login__signup">
                        <div class="kt-login__head">
                            <h3 class="kt-login__title">注册</h3>
                            <div class="kt-login__desc">输入你的账号密码注册</div>
                        </div>
                        <form class="kt-form" onsubmit="return false;" id="signinForm">
                            <div class="center">
                                <label class="kt-radio kt-radio--bold kt-radio--success">
                                    <input type="radio" value="3" name="role" checked> 学生
                                    <span></span>
                                </label>
                                &nbsp;&nbsp;&nbsp;
                                <label class="kt-radio kt-radio--bold kt-radio--success">
                                    <input type="radio" value="2" name="role"> 教师
                                    <span></span>
                                </label>
                            </div>
                            <div class="input-group">
                                <input class="form-control" type="text" placeholder="用户名" name="name" required
                                       autocomplete="off">
                            </div>
                            <div class="input-group">
                                <input class="form-control" type="text" placeholder="真实姓名" name="realname" required>
                            </div>

                            <div class="center mt-3 ml-5">
                                <label class="kt-radio kt-radio--bold kt-radio--success">
                                    <input type="radio" value="1" name="sex" checked> 男
                                    <span></span>
                                </label>
                                &nbsp;&nbsp;&nbsp;
                                <label class="kt-radio kt-radio--bold kt-radio--success">
                                    <input type="radio" value="2" name="sex"> 女
                                    <span></span>
                                </label>
                            </div>
                            <div class="input-group">
                                <input class="form-control" type="text" placeholder="学号(教师不需要填写)" name="code">
                            </div>

                            <div class="input-group">
                                <input class="form-control" type="password" placeholder="密码" name="password" required>
                            </div>


                            <div class="kt-login__actions">
                                <button id="siginin"
                                        class="btn btn-brand btn-elevate kt-login__btn-primary">注册
                                </button>&nbsp;&nbsp;
                                <button id="kt_login_signup_cancel"
                                        class="btn btn-light btn-elevate kt-login__btn-secondary">去登录
                                </button>
                            </div>
                        </form>
                    </div>
                    <div class="kt-login__account">
								<span class="kt-login__account-msg">
									还没有账号？
								</span>
                        &nbsp;&nbsp;
                        <a href="javascript:;" id="kt_login_signup" class="kt-login__account-link">去注册!</a>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

<!-- end:: Page -->

<!-- begin::Global Config(global config for global JS sciprts) -->
<script>
    var KTAppOptions = {
        "colors": {
            "state": {
                "brand": "#5d78ff",
                "dark": "#282a3c",
                "light": "#ffffff",
                "primary": "#5867dd",
                "success": "#34bfa3",
                "info": "#36a3f7",
                "warning": "#ffb822",
                "danger": "#fd3995"
            },
            "base": {
                "label": [
                    "#c5cbe3",
                    "#a1a8c3",
                    "#3d4465",
                    "#3e4466"
                ],
                "shape": [
                    "#f0f3ff",
                    "#d9dffa",
                    "#afb4d4",
                    "#646c9a"
                ]
            }
        }
    };
</script>

<!-- end::Global Config -->

<!--begin::Global Theme Bundle(used by all pages) -->
<script src="/public/assets/plugins/global/plugins.bundle.js" type="text/javascript"></script>
<script src="/public/assets/js/scripts.bundle.js" type="text/javascript"></script>

<!--end::Global Theme Bundle -->

<!--begin::Page Scripts(used by this page) -->
<script src="/public/assets/js/pages/custom/login/login-general.js" type="text/javascript"></script>

<script>


    $('#loginBtn').click(function () {
        var loginForm = $('#loginForm').serialize();
        var params = loginForm.split('&');
        for (var i = 0; i < params.length; i++) {
            var item = params[i].split('=');
            if (item[1] ==""){
                toastr.error('请先将表单填写完整');
                return;
            }
        }
        $.ajax({
            url: '/home/auth/loginLogic',
            data: $('#loginForm').serialize(),
            dataType: 'json',
            type: 'post',
            success: function (result) {
                if (result.code == 0) {
                    toastr.success("登录成功");
                    setTimeout(function () {
                        window.location.href = '/home/index/index'
                    }, 1000);
                } else {
                    toastr.error(result.msg);
                    return;
                }
            }
        })
    })
    $('#siginin').click(function () {

        var loginForm = $('#signinForm').serialize();
        var params = loginForm.split('&');
        for (var i = 0; i < params.length; i++) {
            var item = params[i].split('=');
            if (item[1] ==""){
                toastr.error('请先将表单填写完整');
                return;
            }
        }

        $.ajax({
            url: '/home/auth/register',
            data: $('#signinForm').serialize(),
            dataType: 'json',
            type: 'post',
            success: function (result) {
                if (result.code == 0) {
                    toastr.success("注册成功");
                    window.location.reload();
                } else {
                    toastr.error(result.msg);
                    return;
                }
            }
        })
    })


</script>
<!--end::Page Scripts -->
</body>

<!-- end::Body -->
</html>
